import { http } from "@/utils/http";
import { Result, arrayResult } from "../types";

export type warehouseData = {
  id?: number,
  code?: string,
  name?: string,
  type?: number,
  region?: string,
  inuser?: any,
  outuser?: any,
  address?: string,
  agvids?: any,
  note?: string
};

type warehouseSearch = {
  name: string,
  code: string,
  dateRange: Array<any>,
  pageNumber: number,
  pageSize: number,
  sortName: string,
  sortType: number
}

// 仓库列表
export const wareList = (params?: warehouseSearch) => {
  return http.request<Result>("get", "/api/warehouse/List", { params });
};

// 新增仓库
export const addWare = (data?: warehouseData) => {
  return http.request<Result>("post", "/api/warehouse/Add", { data });
};

// 修改仓库
export const updateWare = (data?: warehouseData) => {
  return http.request<Result>("post", "/api/warehouse/Update", { data });
};

// 删除仓库
export const delWare = (id: number) => {
  return http.request<Result>("post", `/api/warehouse/Delete/${id}`, {});
};

// 管理员列表
export const GetUserByStatus = () => {
  return http.request<arrayResult>("get", "/api/User/GetUserByStatus", {});
};

// 查询仓库列表
export const GetWarehouseList = () => {
  return http.request<arrayResult>("get", "/api/warehouse/GetWarehouseList", {});
};

// 查询所有货位信息
export const GetAllRacklocationsList = (id: number) => {
  return http.request<arrayResult>("get", `/api/racklocations/GetAllRacklocationsList?warehouseId=${id}`, {});
};

// 修改状态
export const racklocationsUpdateStatus = (data: any) => {
  return http.request<Result>("post", `/api/racklocations/UpdateStatus/${data.id}`, { data: data.status });
};

